INCLUDE_DIRECTORIES(BEFORE streflop lua/include ${CMAKE_SOURCE_DIR}/rts/System)

AUX_SOURCE_DIRECTORY(lua/src lualibfiles)
ADD_LIBRARY(lua STATIC ${lualibfiles})
TARGET_LINK_LIBRARIES(lua streflop)
if (UNIX)
	SET_TARGET_PROPERTIES(lua PROPERTIES COMPILE_FLAGS "-DLUA_USE_MKSTEMP ${PIC_FLAG}")
else (UNIX)
	SET_TARGET_PROPERTIES(lua PROPERTIES COMPILE_FLAGS "${PIC_FLAG}")
endif (UNIX)

ADD_DEFINITIONS(-D_SZ_ONE_DIRECTORY)
AUX_SOURCE_DIRECTORY(7zip 7zipfiles)
ADD_LIBRARY(7zip STATIC EXCLUDE_FROM_ALL ${7zipfiles})
SET_TARGET_PROPERTIES(7zip PROPERTIES COMPILE_FLAGS "${PIC_FLAG}")

FIND_PACKAGE(ZLIB REQUIRED)
AUX_SOURCE_DIRECTORY(hpiutil2 hpifiles)
ADD_LIBRARY(hpiutil2 STATIC EXCLUDE_FROM_ALL ${hpifiles})
TARGET_LINK_LIBRARIES(hpiutil2 ${ZLIB_LIBRARY})
SET_TARGET_PROPERTIES(hpiutil2 PROPERTIES COMPILE_FLAGS "${PIC_FLAG}")

AUX_SOURCE_DIRECTORY(oscpack oscfiles)
ADD_LIBRARY(oscpack STATIC EXCLUDE_FROM_ALL ${oscfiles})
IF (APPLE)
	SET_TARGET_PROPERTIES(oscpack PROPERTIES COMPILE_FLAGS -DOSC_HOST_BIG_ENDIAN)
ELSE (APPLE)
	SET_TARGET_PROPERTIES(oscpack PROPERTIES COMPILE_FLAGS -DOSC_HOST_LITTLE_ENDIAN)
ENDIF (APPLE)

AUX_SOURCE_DIRECTORY(gml gmlfiles)
ADD_LIBRARY(gml STATIC EXCLUDE_FROM_ALL ${gmlfiles})
if (MINGW)
	TARGET_LINK_LIBRARIES(gml opengl32 glu32)
else (MINGW)
	TARGET_LINK_LIBRARIES(gml GL GLU)
endif (MINGW)

IF (UNIX)
	ADD_LIBRARY(minizip STATIC EXCLUDE_FROM_ALL minizip/unzip minizip/zip minizip/ioapi)
ELSE (UNIX)
	ADD_LIBRARY(minizip STATIC EXCLUDE_FROM_ALL minizip/unzip minizip/zip minizip/iowin32 minizip/ioapi)
ENDIF (UNIX)
TARGET_LINK_LIBRARIES(minizip ${ZLIB_LIBRARY})
SET_TARGET_PROPERTIES(minizip PROPERTIES COMPILE_FLAGS "${PIC_FLAG}")

ADD_SUBDIRECTORY(streflop)
